import React from 'react'
import TheTable from '@/components/TheTable'
import ThePagination from '@/components/ThePagination'
import {apiGetMhcFeedBackPage} from "@/request/callSetting/feedbackInfo";
import {Tooltip,Typography} from "antd";
const { Paragraph, Text } = Typography;

//反馈信息
export default class FeedbackInfo extends React.Component {
  state = {
    columns: [
      {
        title: 'id',
        dataIndex: 'mhcMemberFeedbackId',
        key: 'mhcMemberFeedbackId',
      },
      {
        title: '用户id',
        dataIndex: 'memberId',
        key: 'memberId',
      },
      {
        title: '用户昵称',
        dataIndex: 'nickName',
        key: 'nickName',
      },
      {
        title: '意见反馈',
        dataIndex: 'opinion',
        key: 'opinion',
        ellipsis: {
          showTitle: false
        },
        render: (text) => {
          return <Text
              style={{width: 500}}
              ellipsis={{
                tooltip: text,
              }}
          >
            {text}
          </Text>
        }
      },
      {
        title: '提交时间',
        dataIndex: 'createTime',
        key: 'createTime',
      },
    ],
    dataSource: [],
    pageData: {
      pageNo: 1,
      pageSize: 10
    },
    total: 0
  }
  componentDidMount() {
    this.getData()
  }
  //获取数据
  getData = async () => {
    apiGetMhcFeedBackPage({...this.state.pageData}).then(res=>{
      if (res.code === 0){
        this.setState({
          dataSource: res.data,
          pageNo: res.pageNo,
          pageSize: res.pageSize,
          total: res.totalCount
        })
      }
    })
  }
  //切换分页
  pageChange = (pageNo, pageSize) => {
    this.setState({
      pageData: { pageNo, pageSize }
    }, () => { this.getData() })
  }
  render() {
    const { columns, dataSource, pageData: { pageNo, pageSize }, total } = this.state
    return (
      <div className='p-layout-box'>
        <div className="p-layout-content-pagination">
          <TheTable rowKey={'mhcMemberFeedbackId'} columns={columns} dataSource={dataSource} />
          <ThePagination pageNo={pageNo} pageSize={pageSize} total={total} pageChange={this.pageChange} />
        </div>
      </div>
    )
  }
}
